package doyouknow.group.CnAndZhb.service.impl;

import doyouknow.group.CnAndZhb.entity.TblCompany;
import doyouknow.group.CnAndZhb.dao.master.TblCompanyDao;
import doyouknow.group.CnAndZhb.service.TblCompanyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TblCompany)表服务实现类
 *
 * @author cn
 * @since 2020-11-03 20:50:41
 */
@Service("tblCompanyService")
public class TblCompanyServiceImpl implements TblCompanyService {
    @Resource
    private TblCompanyDao tblCompanyDao;

    /**
     * 通过ID查询单条数据
     *
     * @param companyidx 主键
     * @return 实例对象
     */
    @Override
    public TblCompany queryById(Integer companyidx) {
        return this.tblCompanyDao.queryById(companyidx);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<TblCompany> queryAllByLimit(int offset, int limit) {
        return this.tblCompanyDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tblCompany 实例对象
     * @return 实例对象
     */
    @Override
    public TblCompany insert(TblCompany tblCompany) {
        this.tblCompanyDao.insert(tblCompany);
        return tblCompany;
    }

    /**
     * 修改数据
     *
     * @param tblCompany 实例对象
     * @return 实例对象
     */
    @Override
    public TblCompany update(TblCompany tblCompany) {
        this.tblCompanyDao.update(tblCompany);
        return this.queryById(tblCompany.getCompanyidx());
    }

    /**
     * 通过主键删除数据
     *
     * @param companyidx 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer companyidx) {
        return this.tblCompanyDao.deleteById(companyidx) > 0;
    }
}